package com.ejuornal.service.impl;

import java.lang.reflect.ParameterizedType;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.ejuornal.bean.Page;
import com.ejuornal.bean.vo.UserSubscibeJudge;
import com.ejuornal.dao.UserSJDao;
import com.ejuornal.service.UserSJService;
@Component("userSJServiceImpl")
public class UserSJServiceImpl implements UserSJService {

	private UserSJDao userSJDao;
	
	public UserSJDao getUserSJDao() {
		return userSJDao;
	}

	@Resource(name="userSJDaoImpl")
	public void setUserSJDao(UserSJDao userSJDao) {
		this.userSJDao = userSJDao;
	}

	@Override
	public Page<UserSubscibeJudge> findAllJudge(int current_record, String url,int categoryId, int userId) {
		// TODO Auto-generated method stub
		String hsql = "where categoryId = " + categoryId + "  AND  status = 1 ";
		return userSJDao.findAllJudge(current_record, url, hsql, userId);
	}

	@Override
	public Page<UserSubscibeJudge> findAllJudge(int current_record, String url,
			int categoryId) {
		// TODO Auto-generated method stub
		String hsql = "where categoryId = " + categoryId + "  AND  status = 1 ";
		return  userSJDao.findAllJudge(current_record, url, hsql);
	}

	@Override
	public Page<UserSubscibeJudge> findSUJByuserId(int current_record,
			String url, int userId) {
		// TODO Auto-generated method stub
	//	SELECT  *  FROM  t_periodical  p ,t_subscribe s WHERE p.periodicalId = s.periodicalId  AND  s.userId = 4
		//String sql = "select count(*) from  t_periodical " +hsql;
		//  sql = "select pubDate,name,periodicalId,cover from  t_periodical " + hsql + " limit " + current_record + "," + page
		String hsql = " , t_subscribe  WHERE t_periodical.periodicalId = t_subscribe.periodicalId  AND  t_subscribe.userId = " + userId;
		return  userSJDao.findAll(current_record, url, hsql);
	}
	
}
